<?php

namespace app\api\controller\god;


use app\common\controller\Api;

class Major extends Api
{
    protected $noNeedRight = '*';
    protected $noNeedLogin = ['lists'];


    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = model('Major');
    }

    public function lists()
    {
        $params = $this->request->param();
        if (empty($params['college_id'])) {
            $this->error('参数错误，学院ID为空');
            return;
        }

        $lists = $this->model->field('id,name,pro_code,read_price,college_id,status')
            ->where('status', 'normal') // 状态正常
            ->where('college_id', intval($params['college_id']))  // 学院的专业
            ->select();
        foreach ($lists as $k => $item) {
            $lists[$k]['read_price_text'] = bcdiv(intval($item['read_price']), 100, 2);
        }

        $this->success('查询成功', $lists);

    }
}